clear all
cd "DEFINE DIRECTORY"
use YalazEtAl_JPR_Data.dta

*Table 1
sutex rebgovbinall comprehensivegov stateconbinall comprehensivecons labordependency statecap_base_fiscal cinc lngdppc tercont ethnicgr centralcomm lnrebelsize extsup mlr mrel, digits(2) lab nobs minmax title("Summary statistics")

*Table 2
eststo m1: logit rebgovbinall labordependency, robust
eststo m2: logit rebgovbinall labordependency cinc lngdppc tercont ethnicgr centralcomm lnrebelsize extsup mlr mrel, robust
eststo m3: logit stateconbinall labordependency, robust 
eststo m4: logit stateconbinall labordependency cinc lngdppc tercont ethnicgr centralcomm lnrebelsize extsup mlr mrel, robust
eststo m5: ologit comprehensivegov labordependency statecap_base_fiscal c.labordependency#c.statecap_base_fiscal, robust
eststo m6: ologit comprehensivegov labordependency statecap_base_fiscal c.labordependency#c.statecap_base_fiscal cinc lngdppc tercont ethnicgr centralcomm lnrebelsize extsup mlr mrel, robust
eststo m7: ologit comprehensivecons labordependency statecap_base_fiscal c.labordependency#c.statecap_base_fiscal, robust
eststo m8: ologit comprehensivecons labordependency statecap_base_fiscal c.labordependency#c.statecap_base_fiscal cinc lngdppc tercont ethnicgr centralcomm lnrebelsize extsup mlr mrel, robust
esttab m1 m2 m3 m4 m5 m6 m7 m8 using "Table_MainAnalysis2.tex", tex replace b(%10.3f) se scalars("r2 \$R^2\$" "ll Log-Likelihood" "aic AIC") label starlevels(* 0.05 ** 0.01 *** 0.001) varlabels(_cons Constant)

*Figure 1
logit rebgovbinall labordependency cinc lngdppc tercont ethnicgr centralcomm lnrebelsize extsup mlr mrel, robust
margins, at(labordependency=(1 (1) 4)) 
marginsplot, legend(position(6))

logit stateconbinall labordependency cinc lngdppc tercont ethnicgr centralcomm lnrebelsize extsup mlr mrel, robust
margins, at(labordependency=(1 (1) 4)) 
marginsplot, legend(position(6))


*Figure 2
ologit comprehensivegov labordependency statecap_base_fiscal c.labordependency#c.statecap_base_fiscal cinc lngdppc tercont ethnicgr centralcomm lnrebelsize extsup mlr mrel, robust
margins, predict(outcome(4)) at(labordependency=(1 (1) 4) statecap_base_fiscal=(-4 2)) 
marginsplot, legend(position(6))

ologit comprehensivegov labordependency statecap_base_fiscal c.labordependency#c.statecap_base_fiscal cinc lngdppc tercont ethnicgr centralcomm lnrebelsize extsup mlr mrel, robust
margins, predict(outcome(4)) dydx(statecap_base_fiscal) at(labordependency=(1 (1) 4))
marginsplot, yline(0)  addplot(hist labordependency, yaxis(2) yscale(alt) fcolor(%25) lc(black%50))



*Figure 3
ologit comprehensivecons labordependency statecap_base_fiscal c.labordependency#c.statecap_base_fiscal cinc lngdppc tercont ethnicgr centralcomm lnrebelsize extsup mlr mrel, robust
margins, predict(outcome(3)) at(labordependency=(1 (1) 4) statecap_base_fiscal=(-4 2)) 
mplotoffset, offset(0.08) legend(position(6))


ologit comprehensivecons labordependency statecap_base_fiscal c.labordependency#c.statecap_base_fiscal cinc lngdppc tercont ethnicgr centralcomm lnrebelsize extsup mlr mrel, robust
margins, predict(outcome(3)) dydx(statecap_base_fiscal) at(labordependency=(1 (1) 4))
marginsplot, yline(0)  addplot(hist labordependency, yaxis(2) yscale(alt) fcolor(%25) lc(black%50))




*ONLINE APPENDIX

*Part C.
eststo m1: logit econsocgov	labordependency, robust 
eststo m2: logit econsocgov	labordependency cinc lngdppc tercont ethnicgr centralcomm lnrebelsize extsup mlr mrel, robust 
eststo m3: nbreg econsocindex labordependency, robust 
eststo m4: nbreg econsocindex labordependency cinc lngdppc tercont ethnicgr centralcomm lnrebelsize extsup mlr mrel, robust
eststo m5: nbreg consintensity labordependency, robust
eststo m6:nbreg consintensity labordependency cinc lngdppc tercont ethnicgr centralcomm lnrebelsize extsup mlr mrel, robust
esttab m1 m2 m3 m4 m5 m6 using "AlterDVH1a-b1AAA.tex", tex replace b(%10.3f) se scalars("ll Log-Likelihood" "aic AIC") label starlevels(* 0.05 ** 0.01 *** 0.001) varlabels(_cons Constant)

*Part D.
eststo m1: logit econsocgov	labordependency statecap_base_fiscal c.labordependency#c.statecap_base_fiscal, robust 
eststo m2: logit econsocgov	labordependency statecap_base_fiscal c.labordependency#c.statecap_base_fiscal cinc lngdppc tercont ethnicgr centralcomm lnrebelsize extsup mlr mrel, robust 
eststo m3:nbreg econsocindex labordependency statecap_base_fiscal c.labordependency#c.statecap_base_fiscal, robust
eststo m4:nbreg econsocindex labordependency statecap_base_fiscal c.labordependency#c.statecap_base_fiscal cinc lngdppc tercont ethnicgr centralcomm lnrebelsize extsup mlr mrel, robust
eststo m5:nbreg consintensity labordependency statecap_base_fiscal c.labordependency#c.statecap_base_fiscal, robust
eststo m6:nbreg consintensity labordependency statecap_base_fiscal c.labordependency#c.statecap_base_fiscal cinc lngdppc tercont ethnicgr centralcomm lnrebelsize extsup mlr mrel, robust
esttab m1 m2 m3 m4 m5 m6 using "AlterDVH2a-b1AAA.tex", tex replace b(%10.3f) se scalars("ll Log-Likelihood" "aic AIC") label starlevels(* 0.05 ** 0.01 *** 0.001) varlabels(_cons Constant)

*Part E.
eststo m1:ologit comprehensivegov labordependency v2stfisccap c.labordependency#c.v2stfisccap, robust
eststo m2:ologit comprehensivegov labordependency v2stfisccap c.labordependency#c.v2stfisccap cinc lngdppc tercont ethnicgr centralcomm lnrebelsize extsup mlr mrel, robust
eststo m3:ologit comprehensivecons labordependency v2stfisccap c.labordependency#c.v2stfisccap, robust
eststo m4:ologit comprehensivecons labordependency v2stfisccap c.labordependency#c.v2stfisccap cinc lngdppc tercont ethnicgr centralcomm lnrebelsize extsup mlr mrel, robust
esttab m1 m2 m3 m4 using "AlterModerator1.tex", tex replace b(%10.3f) se scalars("ll Log-Likelihood" "aic AIC") label starlevels(* 0.05 ** 0.01 *** 0.001) varlabels(_cons Constant)

*Part F.
eststo m1: reg comprehensivegov labordependency statecap_base_fiscal c.labordependency#c.statecap_base_fiscal, robust
eststo m2: reg comprehensivegov labordependency statecap_base_fiscal c.labordependency#c.statecap_base_fiscal cinc lngdppc tercont ethnicgr centralcomm lnrebelsize extsup mlr mrel, robust
eststo m3: reg comprehensivecons labordependency statecap_base_fiscal c.labordependency#c.statecap_base_fiscal, robust
eststo m4: reg comprehensivecons labordependency statecap_base_fiscal c.labordependency#c.statecap_base_fiscal cinc lngdppc tercont ethnicgr centralcomm lnrebelsize extsup mlr mrel, robust
esttab m1 m2 m3 m4 using "AlterEstimH2a-b1.tex", tex replace b(%10.3f) se scalars("r2 \$R^2\$" "aic AIC") label starlevels(* 0.05 ** 0.01 *** 0.001) varlabels(_cons Constant)

*Part G.
eststo m1: logit rebgovbinall labordependency, cluster(sideb_id)
eststo m2: logit rebgovbinall labordependency cinc lngdppc tercont ethnicgr centralcomm lnrebelsize extsup mlr mrel, cluster(sideb_id)
eststo m3: logit stateconbinall labordependency, cluster(sideb_id) 
eststo m4: logit stateconbinall labordependency cinc lngdppc tercont ethnicgr centralcomm lnrebelsize extsup mlr mrel, cluster(sideb_id)
eststo m5: ologit comprehensivegov labordependency statecap_base_fiscal c.labordependency#c.statecap_base_fiscal, cluster(ccode)
eststo m6: ologit comprehensivegov labordependency statecap_base_fiscal c.labordependency#c.statecap_base_fiscal cinc lngdppc tercont ethnicgr centralcomm lnrebelsize extsup mlr mrel, cluster(ccode)
eststo m7: ologit comprehensivecons labordependency statecap_base_fiscal c.labordependency#c.statecap_base_fiscal, cluster(ccode)
eststo m8: ologit comprehensivecons labordependency statecap_base_fiscal c.labordependency#c.statecap_base_fiscal cinc lngdppc tercont ethnicgr centralcomm lnrebelsize extsup mlr mrel, cluster(ccode)
esttab m1 m2 m3 m4 m5 m6 m7 m8 using "ClusterErrors1.tex", tex replace b(%10.3f) se scalars("r2 \$R^2\$" "ll Log-Likelihood" "aic AIC") label starlevels(* 0.05 ** 0.01 *** 0.001) varlabels(_cons Constant)

*Part H.
eststo m1: logit rebgovbinall labordependency cinc lngdppc tercont ethnicgr centralcomm lnrebelsize extsup mlr mrel aveideolrebdist, robust
eststo m2: logit rebgovbinall labordependency cinc lngdppc tercont ethnicgr centralcomm lnrebelsize extsup mlr mrel intergroupfight, robust
eststo m3: logit rebgovbinall labordependency cinc lngdppc tercont ethnicgr centralcomm lnrebelsize extsup mlr mrel norebel, robust

eststo m4: logit stateconbinall labordependency cinc lngdppc tercont ethnicgr centralcomm lnrebelsize extsup mlr mrel aveideolrebdist, robust
eststo m5: logit stateconbinall labordependency cinc lngdppc tercont ethnicgr centralcomm lnrebelsize extsup mlr mrel intergroupfight, robust
eststo m6: logit stateconbinall labordependency cinc lngdppc tercont ethnicgr centralcomm lnrebelsize extsup mlr mrel norebel, robust

eststo m7: ologit comprehensivegov labordependency statecap_base_fiscal c.labordependency#c.statecap_base_fiscal cinc lngdppc tercont ethnicgr centralcomm lnrebelsize extsup mlr mrel aveideolrebdist, robust
eststo m8: ologit comprehensivegov labordependency statecap_base_fiscal c.labordependency#c.statecap_base_fiscal cinc lngdppc tercont ethnicgr centralcomm lnrebelsize extsup mlr mrel intergroupfight, robust
eststo m9: ologit comprehensivegov labordependency statecap_base_fiscal c.labordependency#c.statecap_base_fiscal cinc lngdppc tercont ethnicgr centralcomm lnrebelsize extsup mlr mrel norebel, robust

eststo m10: ologit comprehensivecons labordependency statecap_base_fiscal c.labordependency#c.statecap_base_fiscal cinc lngdppc tercont ethnicgr centralcomm lnrebelsize extsup mlr mrel aveideolrebdist, robust
eststo m11: ologit comprehensivecons labordependency statecap_base_fiscal c.labordependency#c.statecap_base_fiscal cinc lngdppc tercont ethnicgr centralcomm lnrebelsize extsup mlr mrel intergroupfight, robust
eststo m12: ologit comprehensivecons labordependency statecap_base_fiscal c.labordependency#c.statecap_base_fiscal cinc lngdppc tercont ethnicgr centralcomm lnrebelsize extsup mlr mrel norebel, robust

esttab m1 m2 m3 m4 m5 m6 m7 m8 m9 m10 m11 m12 using "RebelCompet.tex", tex replace b(%10.3f) se scalars("r2 \$R^2\$" "ll Log-Likelihood" "aic AIC") label starlevels(* 0.05 ** 0.01 *** 0.001) varlabels(_cons Constant)

*Part I.
eststo m1: logit rebgovbinall labordependency cinc lngdppc tercont ethnicgr centralcomm lnrebelsize extsup mlr mrel counter counter2 counter3, robust
eststo m2: logit stateconbinall labordependency cinc lngdppc tercont ethnicgr centralcomm lnrebelsize extsup mlr mrel counter counter2 counter3, robust
eststo m3: ologit comprehensivegov labordependency statecap_base_fiscal c.labordependency#c.statecap_base_fiscal cinc lngdppc tercont ethnicgr centralcomm lnrebelsize extsup mlr mrel counter counter2 counter3, robust
eststo m4: ologit comprehensivecons labordependency statecap_base_fiscal c.labordependency#c.statecap_base_fiscal cinc lngdppc tercont ethnicgr centralcomm lnrebelsize extsup mlr mrel counter counter2 counter3, robust
esttab m1 m2 m3 m4 using "Polynomials.tex", tex replace b(%10.3f) se scalars("r2 \$R^2\$" "ll Log-Likelihood" "aic AIC") label starlevels(* 0.05 ** 0.01 *** 0.001) varlabels(_cons Constant)


*Part J. Marginal Effect of Labor Dependency
ologit comprehensivegov labordependency statecap_base_fiscal c.labordependency#c.statecap_base_fiscal cinc lngdppc tercont ethnicgr centralcomm lnrebelsize extsup mlr mrel, robust
margins, predict(outcome(4)) dydx(labordependency) at(statecap_base_fiscal=(-5 (1) 3))
marginsplot, yline(0) addplot(hist statecap_base_fiscal, yaxis(2) fcolor(%25) lc(black%50))

ologit comprehensivecons labordependency statecap_base_fiscal c.labordependency#c.statecap_base_fiscal cinc lngdppc tercont ethnicgr centralcomm lnrebelsize extsup mlr mrel, robust
margins, predict(outcome(3)) dydx(labordependency) at(statecap_base_fiscal=(-5 (1) 3))
marginsplot, yline(0) addplot(hist statecap_base_fiscal, yaxis(2) yscale(alt) fcolor(%25) lc(black%50))

*Robustness - Distribution problem
logit rebgovbinall labordependency cinc lngdppc tercont ethnicgr centralcomm lnrebelsize extsup mlr mrel, robust
matrix input b = (.65, 140, .48, 1.5, -.11, 1.01, .24, .92, -.68, .79, -8)
matrix colnames b = labordependency cinc lngdppc tercont ethnicgr centralcomm lnrebelsize extsup mlr mrel _cons
lroc rebgovbinall, beta(b) nograph
lsens rebgovbinall, beta(b)
prtab rebgovbinall labordependency
